package com.lgx.mall.business.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lgx.common.basic.dao.GeneralJdbcDao;
import com.lgx.common.exception.DataException;
import com.lgx.common.web.Pagination;
import com.lgx.mall.business.dao.IConsumerInfoDao;
import com.lgx.mall.business.entity.ConsumerInfo;
import com.lgx.mall.business.service.IConsumerInfoService;
import com.lgx.right.entity.User;

@Service("consumerInfoService")
public class ConsumerInfoService implements IConsumerInfoService {

	@Autowired
	private IConsumerInfoDao consumerInfoDao;

	public IConsumerInfoDao getConsumerInfoDao() {
		return consumerInfoDao;
	}

	public void setConsumerInfoDao(IConsumerInfoDao consumerInfoDao) {
		this.consumerInfoDao = consumerInfoDao;
	}
	
	@Autowired
	private GeneralJdbcDao baseDao;
	
	public GeneralJdbcDao getBaseDao() {
		return baseDao;
	}

	public void setBaseDao(GeneralJdbcDao baseDao) {
		this.baseDao = baseDao;
	}
	
	public ConsumerInfo createConsumerInfo(ConsumerInfo consumerInfo)throws DataException{
		return consumerInfoDao.createConsumerInfo(consumerInfo);
	}
	
	public ConsumerInfo findConsumerInfoById(long id) {
		return consumerInfoDao.findConsumerInfoById(id);
	}
	
	public Pagination findConsumerInfoPagination(Object[] params, int pageSize, int pageNum){
		return this.consumerInfoDao.findConsumerInfoPagination(params, pageSize, pageNum);
	}
	
	public List<User> findUserByCardIdOrMobile(String userCardIdOrMobile){
		return this.consumerInfoDao.findUserByCardIdOrMobile(userCardIdOrMobile);
	}

	/**
	 * 根据用户id检索消费记录
	 */
	@Override
	public List<ConsumerInfo> findConsumerInfos(Long userId) {
		return this.consumerInfoDao.findConsumerInfos(userId);
	}

	@Override
	public void updateRechargeInfo(ConsumerInfo consumerInfo) throws DataException {
		this.consumerInfoDao.updateRechargeInfo(consumerInfo);
	}
}
